package com.mlethe.library.widget.gesturelock;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint.Style;

/**
 * @author Mlethe
 */
public class GestureLockView2 extends GestureLockView {

    public GestureLockView2(Context context) {
        super(context);
        mPaint.setStyle(Style.FILL);
    }

    public GestureLockView2(Context context, int colorNoFinger, int colorFingerOn, int colorCorrect, int colorError, boolean lockViewDotShow, float arrowRate) {
        super(context, colorNoFinger, colorFingerOn, colorCorrect, colorError, lockViewDotShow, arrowRate);
        mPaint.setStyle(Style.FILL);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        //内圆的半径 = mInnerCircleRadiusRate * mRadius
        float mInnerCircleRadiusRate = 0.325f;
        switch (mCurrentStatus) {
            case STATUS_FINGER_ON:
                // 绘制外圆
                mPaint.setColor(mColorFingerOn);
                mPaint.setAlpha(38);
                canvas.drawCircle(mCenterX, mCenterY, mRadius, mPaint);
                // 绘制内圆
                mPaint.setAlpha(255);
                canvas.drawCircle(mCenterX, mCenterY, mRadius * mInnerCircleRadiusRate, mPaint);
                break;
            case STATUS_FINGER_UP:
                // 绘制外圆
//                if (GestureLockViewGroup.isCorrect)
                switch (mVerifyStatus) {
                    case NO_VERIFY:
                        return;
                    case VERIFY_SUCCESS:
                        mPaint.setColor(mColorFingerUpCorrect);
                        mPaint.setAlpha(38);
                        break;
                    case VERIFY_ERROR:
                        mPaint.setColor(mColorFingerUpError);
                        mPaint.setAlpha(38);
                        break;
                }

                canvas.drawCircle(mCenterX, mCenterY, mRadius, mPaint);
                // 绘制内圆
                mPaint.setAlpha(255);
                canvas.drawCircle(mCenterX, mCenterY, mRadius * mInnerCircleRadiusRate, mPaint);
                drawArrow(canvas);
                break;
            case STATUS_NO_FINGER:
                // 绘制内圆
                mPaint.setAlpha(255);
                mPaint.setColor(mColorNoFinger);
                canvas.drawCircle(mCenterX, mCenterY, mRadius * mInnerCircleRadiusRate, mPaint);
                break;
        }
    }

}
